package com.qcs.sleep.call;

import java.util.Observable;
import java.util.Observer;

/**
 * Created by chshqiang on 15-7-21.
 * 用于通知所有的 Observer
 */
public class TimeChanger extends Observable {
    private static final TimeChanger TIME_CHANGER = new TimeChanger();

    private TimeChanger() {
    }

    public static TimeChanger getInstance() {
        return TIME_CHANGER;
    }

    public void send() {
        setChanged();
        notifyObservers(System.currentTimeMillis());
    }

    @Override
    public void addObserver(Observer observer) {
        if (observer instanceof TimeWatcher)
            super.addObserver(observer);
    }

    @Override
    public synchronized void deleteObserver(Observer observer) {
        if (observer instanceof TimeWatcher)
            super.deleteObserver(observer);
    }
}
